/*
 ============================================================================
 Name        : motion-estim.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>

#include "frame.h"

unsigned int sad(int x, int y, int r, int s){
	register unsigned int sad = 0;
	register int diff1;
	register unsigned int i, j;

	for(i=0; i<16; i++){
		for(j=0; j<16; j++){
			diff1 = frameA[x+i][y+j] - frameB[x+r+i][y+s+j];
			
			if(diff1 < 0){
				sad -= diff1;
			} else {
				sad += diff1;
			}
		}
	}
	return sad;
}

int main (){
	int xRow, yCol, rRow, sCol;

	for(xRow=0; xRow<64; xRow=xRow+16){
		for(yCol=0; yCol<640; yCol=yCol+16){
			for(rRow=0; rRow<480; rRow=rRow+16){
				if(xRow+rRow >= 480)
					break;
				for(sCol=0; sCol<640; sCol=sCol+16){
					if(yCol+sCol >= 640)
						break;
					sad(xRow, yCol, rRow, sCol);
				}
			}
		}
	}

	return 0;
}

